/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package handlers;

import database.Database;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import model.ProductGroup;

/**
 *
 * @author Allan
 */
public abstract class ProductGroupHandler
{
    public static ArrayList<ProductGroup> getAllProductGroups() throws ClassNotFoundException, SQLException
    {
        Database db = new Database();
        db.connectToDB();
        ResultSet rs = db.query("CALL getAllProductGroups()");
        
        ArrayList<ProductGroup> toReturn = new ArrayList();
        
        toReturn.add(new ProductGroup(0, "Alle varer"));
        
        if(rs.isBeforeFirst())
        {
            while(rs.next())
            {
                toReturn.add(new ProductGroup(rs.getInt("varegruppeID"), rs.getString("varegruppeNavn")));
            }
        }
        
        db.closeDB();
        return toReturn;
    }
}
